//
//  MethodDefine.h
//  HealthStarApp
//
//  Created by 朱慕之 on 2019/5/15.
//  Copyright © 2019 zhumuzhi. All rights reserved.
//  常用方法宏定义

#ifndef MethodDefine_h
#define MethodDefine_h

/**
 头文件说明：
 1、常用方法声明
 */

#pragma mark - ************************** NSLog *********************************
// 重定义NSLog，清除控制台无用log信息，当在debug模式时打印详细日志，在release模式时不打印详细日志
#ifdef DEBUG
// 方式1 每次换行
//#define NSLog(format, ...) printf("\n<<<<<<<<<<<<@@@\n\n[%s] %s [Line %d]:\n \n%s\n\n@@@>>>>>>>>>>>>\n", __TIME__, __FUNCTION__, __LINE__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String]);

// 方式2 中文说明
//# define NSLog(fmt, ...) NSLog((@"[%s]" "[Line:%d] " fmt), __FUNCTION__, __LINE__, ##__VA_ARGS__);

//#define NSLog(format, ...) printf("[%s] [%s] [Line %d] %s\n", __TIME__, __FUNCTION__, __LINE__, [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String]);

#define NSLog(format, ...)   fprintf(stderr, "[%s : Line%d] %s\n", \
[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __func__); \
(NSLog)((format), ##__VA_ARGS__); \

// 方式3 纯内容
//#define NSLog(format, ...) printf("%s\n", [[NSString stringWithFormat:(format), ##__VA_ARGS__] UTF8String]);
#else
#define NSLog(...) {}
#endif

#pragma mark - ************************** 图片加载 *********************************
//图片的宏定义
#define LOADIMAGE(file,ext) [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@%@",file,iPhone6Plus ? @"@3x" : @"@2x"] ofType:ext]]

#define LoadImageByName(imgName)  [UIImage imageNamed:imgName] //加载图片
#define LoadImageByFilePath(fileName)  [UIImage imageWithContentsOfFile:fileName] //加载文件图片


#pragma mark - ************************** Alert *********************************
#define KAlert(title,msg) [[[UIAlertView alloc] initWithTitle:title message:msg delegate:nil cancelButtonTitle:@"确定" otherButtonTitles:nil] show]

#pragma mark - ************************** 获取系统时间戳 *********************************
//获取系统时间戳
#define  kSystemTimeStamp [NSString stringWithFormat:@"%ld", (long)[[NSDate date] timeIntervalSince1970]]


#pragma mark - *************************************ios11适配相关宏定义：*************************************
//1、适配ios11+scrollview向下偏移问题
#define  adjustsScrollViewInsets_NO(scrollView,vc)\
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
if ([UIScrollView instancesRespondToSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:")]) {\
[scrollView   performSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:") withObject:@(2)];\
} else {\
vc.automaticallyAdjustsScrollViewInsets = NO;\
}\
_Pragma("clang diagnostic pop") \
} while (0)


#pragma mark - ************************** 商品图片显示比例修改宏 *********************************

#define kScaleImageUrl(imageUrl, style)  [[imageUrl stringByReplacingOccurrencesOfString:@"marking_text" withString:style] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
/** 图片比例 150-200-350-marking_text */
#define style150 @"style150"
#define style200 @"style200"
#define style350 @"style350"
#define marking_text @"marking_text"


#endif /* MZMethodDefine_h */
